package servlets;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import modelo.Advogado;
import negocio.AdvogadoLogic;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class ConsultaAdvogado
 */
public class ConsultaAdvogado extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ConsultaAdvogado() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		List <Advogado> listaAdvogados = new ArrayList<Advogado>();
		String opcao = request.getParameter("busca");
		String texto = request.getParameter("texto");
		
		AdvogadoLogic logic = new AdvogadoLogic();
		listaAdvogados = logic.buscarAdvogado(opcao, texto);
		
		request.setAttribute("listaAdvogados", listaAdvogados);
		RequestDispatcher rd = request.getRequestDispatcher("consultaAdvogado.jsp");
		rd.forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		
		
	}

}
